//
//  ZMAlert.m
//  testDemo
//
//  Created by 赵林瑞 on 16/7/6.
//  Copyright © 2016年 RZOL. All rights reserved.
//

#import "ZMAlert.h"
#import "UIView+MTExtension.h"



@interface ZMAlert ()

@property (nonatomic, strong) UILabel *titleLab;
@property (nonatomic, strong) UILabel *textLab;

@property (nonatomic, strong) UIButton *cancleBtn;
@property (nonatomic, strong) UIButton *sureBtn;

@property (nonatomic, strong) UIView *line1;
@property (nonatomic, strong) UIView *line2;

@end

@implementation ZMAlert

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self titleLab];
        [self textLab];
        [self line1];
        [self line2];
        [self cancleBtn];
        [self sureBtn];
    }
    return self;
}

- (UILabel *)titleLab {
    if (!_titleLab) {
        _titleLab = [UILabel new];
        _titleLab.font = LAB_FONT(14);
        _titleLab.textColor = HEXCOLOR(0x333333);
        _titleLab.text = @"温馨提示";
        [_titleLab sizeToFit];
        _titleLab.textAlignment = NSTextAlignmentCenter;
        [self addSubview:_titleLab];
        
        _titleLab.center = CGPointMake(self.width/2.f, self.height/145.f*25.f);
    }
    return _titleLab;
}

- (UILabel *)textLab {
    if (!_textLab) {
        _textLab = [UILabel new];
        _textLab.font = LAB_FONT(12);
        _textLab.textColor = HEXCOLOR(0x333333);
        _textLab.text = @"您还不是VIP用户，无法进行此操作，是否充值成为VIP";
        _textLab.width = self.width*0.85;
        _textLab.height = self.height * 0.25;
        _textLab.textAlignment = NSTextAlignmentCenter;
        _textLab.numberOfLines = 2;
        [self addSubview:_textLab];
        
        _textLab.center = CGPointMake(self.width/2.f, self.height/2.f-10);
    }
    return _textLab;
}

- (UIButton *)cancleBtn {
    if (!_cancleBtn) {
        _cancleBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _cancleBtn.width = self.width*0.5-2;
        _cancleBtn.height = self.height*0.24;
        _cancleBtn.x = 0;
        _cancleBtn.y = self.height*0.76;
        
        [_cancleBtn setTitle:@"取消" forState:UIControlStateNormal];
        [_cancleBtn setTitleColor:HEXCOLOR(0x289eff) forState:UIControlStateNormal];
        
        [self addSubview:_cancleBtn];
    }
    return _cancleBtn;
}

- (UIButton *)sureBtn {
    if (!_sureBtn) {
        _sureBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _sureBtn.width = self.width*0.5-2;
        _sureBtn.height = self.height*0.24;
        _sureBtn.x = self.width-_sureBtn.width;
        _sureBtn.y = self.height*0.76;
        
        [_sureBtn setTitle:@"确定" forState:UIControlStateNormal];
        [_sureBtn setTitleColor:HEXCOLOR(0x289eff) forState:UIControlStateNormal];
        
        [self addSubview:_sureBtn];
    }
    return _sureBtn;
}

- (UIView *)line1 {
    if (!_line1) {
        _line1 = [[UIView alloc] initWithFrame:CGRectMake(0, self.height*0.75, self.width, 0.5)];
        _line1.backgroundColor = HEXCOLOR(0xdddddd);
        [self addSubview:_line1];
    }
    return _line1;
}

- (UIView *)line2 {
    if (!_line2) {
        _line2 = [[UIView alloc] initWithFrame:CGRectMake(self.width/2.f-0.25, self.height*0.75 + 2, 0.5, self.height*0.25-4)];
        _line2.backgroundColor = HEXCOLOR(0xdddddd);
        [self addSubview:_line2];
    }
    return _line2;
}

@end
